package filedemo;

public class Main4 {
    public static void main(String[] args) {
        try {
            java.io.BufferedWriter out = new java.io.BufferedWriter(new java.io.FileWriter("filename"));
            out.write("aString1\n");
            out.close();
            out = new java.io.BufferedWriter(new java.io.FileWriter("filename", true));
            out.write("aString2");
            out.close();
            java.io.BufferedReader in = new java.io.BufferedReader(new java.io.FileReader("filename"));
            String str;
            while ((str = in.readLine()) != null) {
                System.out.println(str);
            }
            in.close();
        } catch (java.io.IOException e) {
            System.out.println("exception occoured" + e);
            throw new RuntimeException(e);
        }
    }
}
